home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14023 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.8 KB

  1. Path: news.orl.mmc.com!usenet
  2. From: Ted Dennison <dennison@escmail.orl.mmc.com>
  3. Newsgroups: comp.lang.ada,comp.lang.c++
  4. Subject: Re: some questions re. Ada/GNAT from a C++/GCC user
  5. Date: Thu, 28 Mar 1996 12:01:27 -0500
  6. Organization: Lockheed Martin Marine Systems
  7. Message-ID: <315AC5E7.3A77@escmail.orl.mmc.com>
  8. References: <wnewmanDoxrCp.DKv@netcom.com>
  9. NNTP-Posting-Host: bubba_4.orl.mmc.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.01 (X11; I; HP-UX A.09.01 9000/750)
  14.  
  15. Bill Newman wrote:
  16. > Does GNAT completely implement generics as defined in the standard?
  17. > (I ask because I have heard that no compiler, G++ otherwise, has yet
  18. > implemented C++ templates completely, and the G++ implementation
  19. > caused me lots of hassles before 2.7.x, and still causes some hassles
  20. > now.)
  21.  
  22. The environment in the Ada community is such that the community won't
  23. accept an Ada compiler that doesn't match the standard, except in some
  24. extreme circumstances (such as embedded programming). If it is in the
  25. Ada standard, then you can pretty much count on an Ada compiler 
  26. implementing it as specified (barring bugs of course).
  27.  
  28. > When I make two different instantiations of a generic package with the
  29. > same arguments, I understand the compiler treats them formally as two
  30. > different packages, which is OK with me.  However, I'd appreciate
  31. > knowing the compiler wouldn't actually output two redundant copies of
  32. > the corresponding (identical?) machine code, but instead share the
  33. > code.  I saw somewhere that the compiler is given considerable freedom
  34. > to share one instantiation between several arguments if it thinks it's
  35. > appropriate, which is also OK with me.  However, I haven't seen any
  36. > guarantee that the compiler won't output redundant copies for
  37. > instantiations with identical arguments.  Is there such a guarantee?
  38.  
  39. If you want a guarantee, put the code you want shared in a non-generic
  40. package or procedure, and call it from your generic package or
  41. procedure.
  42.  
  43. > Why doesn't Ada 95 allow declarations to be interspersed with ordinary
  44. > statements as C++ does?  (Or does it?  _Ada as a Second Language_ is a
  45. > big book!)  It seems to me that the C++ approach is a small but
  46. > definite win.  Does it interact very badly somehow with all those
  47. > guarantees on elaboration order?
  48.  
  49. Not really. If you want to declare variables later in the code just 
  50. use a declare block:
  51.    declare
  52.       Var1 : My_Type;
  53.       ...
  54.    begin
  55.       Var1 := My_Value;
  56.       ...
  57.    end;
  58.  
  59. This has the added benefit of limiting the scope of Var1 to the
  60. begin..end
  61. block of code.
  62.  
  63. (paraphrase: where are macros?)
  64.  
  65. I hate macros!!! Anyone who has has ever tried to compile emacs from
  66. sources should agree with me. Anyone who has ever tried to figure out
  67. "portable" C code should agree with me. Practically all of the
  68. functionality of macros can be implemented in Ada in other ways. Ways
  69. that are much easier to understand and maintain.
  70.  
  71. And lastly, if you really like them, implement your own pre-processor.
  72. You wouldn't be the first.
  73.  
  74. > Finally, I found it intriguing when someone (somewhere in the endless
  75. > C++ vs. Ada thread) described a program which used exceptions to
  76. > convert runtime errors to `graceful degradation' so successfully that
  77. > the program (for fire control?!) continued operating more-or-less
  78.  
  79. If you are mostly doing command processing (and no human lives are at
  80. stake), this makes perfect sense. Just because there is some kind of 
  81. problem (or exceptional condition) with one command doesn't mean the 
  82. others can't work perfectly. In this case, why core dump? Just log the 
  83. problem and continue.
  84.  
  85.  
  86. -- 
  87. T.E.D.          
  88.                 |  Work - mailto:dennison@escmail.orl.mmc.com  |
  89.                 |  Home - mailto:dennison@iag.net              |
  90.                 |  URL  - http://www.iag.net/~dennison         |
  91.